USE [VIETPUBLISHER]
GO

/****** Object:  Table [dbo].[T_BK_Book]    Script Date: 06/14/2012 23:25:58 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[T_BK_Book](
	[BookID] [int] IDENTITY(1,1) NOT NULL,
	[BookTitle] [nvarchar](100) NULL,
	[Description] [nvarchar](2000) NULL,
	[PictureID] [int] NULL,
	[Size] [nvarchar](15) NULL,
	[Weight] [nvarchar](15) NULL,
	[PublisherDate] [datetime] NULL,
	[Language] [nvarchar](30) NULL,
	[PageNumber] [nvarchar](15) NULL,
	[Quantity] [int] NULL,
	[ViewTimes] [int] NULL,
	[PublisherID] [int] NULL,
	[AuthorGroupID] [int] NULL,
	[CategoryID] [int] NULL,
	[Translator] [nvarchar](50) NULL,
	[PriceCurrent] [float] NULL,
	[BookCode] [varchar](15) NULL,
 CONSTRAINT [PK_Book] PRIMARY KEY CLUSTERED 
(
	[BookID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'the quantity  of the book inputting
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_BK_Book', @level2type=N'COLUMN',@level2name=N'Quantity'
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'The view times of a book
' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'T_BK_Book', @level2type=N'COLUMN',@level2name=N'ViewTimes'
GO

ALTER TABLE [dbo].[T_BK_Book]  WITH CHECK ADD  CONSTRAINT [FK_Book_AuthorGroup] FOREIGN KEY([AuthorGroupID])
REFERENCES [dbo].[T_BK_AuthorGroup] ([AuthorGroupID])
GO

ALTER TABLE [dbo].[T_BK_Book] CHECK CONSTRAINT [FK_Book_AuthorGroup]
GO

ALTER TABLE [dbo].[T_BK_Book]  WITH CHECK ADD  CONSTRAINT [FK_Book_Category] FOREIGN KEY([CategoryID])
REFERENCES [dbo].[T_BK_Category] ([CategoryID])
GO

ALTER TABLE [dbo].[T_BK_Book] CHECK CONSTRAINT [FK_Book_Category]
GO

ALTER TABLE [dbo].[T_BK_Book]  WITH CHECK ADD  CONSTRAINT [FK_Book_FileGroup] FOREIGN KEY([PictureID])
REFERENCES [dbo].[T_BK_FileGroup] ([GroupId])
GO

ALTER TABLE [dbo].[T_BK_Book] CHECK CONSTRAINT [FK_Book_FileGroup]
GO

ALTER TABLE [dbo].[T_BK_Book]  WITH CHECK ADD  CONSTRAINT [FK_Book_Publisher] FOREIGN KEY([PublisherID])
REFERENCES [dbo].[T_BK_Publisher] ([PublisherID])
GO

ALTER TABLE [dbo].[T_BK_Book] CHECK CONSTRAINT [FK_Book_Publisher]
GO

ALTER TABLE [dbo].[T_BK_Book] ADD  CONSTRAINT [DF_T_BK_Book_ViewTimes]  DEFAULT ((0)) FOR [ViewTimes]
GO

ALTER TABLE [dbo].[T_BK_Book] ADD  CONSTRAINT [DF_T_BK_Book_PriceCurrent]  DEFAULT ((0)) FOR [PriceCurrent]
GO


